﻿using System.Collections.Generic;
using System.Web.Mvc;
using Tss.MagicWeb.Domain.Infrastructure.Auth;
using Tss.MagicWeb.Filters;
using Tss.MagicWeb.Kernel;
using Tss.MagicWeb.ViewModels;

namespace Tss.MagicWeb.Controllers
{
    [AuthenticationFilter(false)]
    public class MainMenuController : Controller
    {
        public override string Name
        {
            get
            {
                return "MainMenu";
            }
        }
        //
        // GET: /MainMenu/

        public ActionResult Get()
        {
            var model = new MainMenuContainer
                {
                    Items = new List<MainMenuItem>
                        {
                            new MainMenuItem { Action = Constants.Mvc.Action.Index, Controller = Constants.Mvc.Controller.Home, AlignedToRight = false, Text = "Home"},
                        }
                };

            if (LoginUtils.CurrentUser != null && LoginUtils.CurrentUser.IsLogged)
            {
                model.Items.Add(new MainMenuItem { Action = Constants.Mvc.Action.Logout, Controller = Constants.Mvc.Controller.Account, AlignedToRight = true, Text = "Log Out" });
            }
            else
            {
                model.Items.Add(new MainMenuItem { OnClick = "$('#loginForm').modal('toggle')", AlignedToRight = true, Text = "Login / Register"});
            }

            return PartialView("MainMenu", model);
        }

    }
}
